var util = {};

util.cookie = (function() {
	return {
		put: function(key, value) {
			var date = new Date();
			date.setTime(date.getTime() + 30 * 12 * 100 * 24 * 3600 * 1000);
			document.cookie = key + "=" + escape(value) + "; expires=" + date.toGMTString();
		},
		get: function(key) {
			//var arr = document.cookie.match(new RegExp("(^| )"+key+"=([^;]*)(;|$)"));
			//if(arr != null) return unescape(arr[2]); return null;
			var arrStr = document.cookie.split("; ");
			var cookStr = "";
			for (var i = 0; i < arrStr.length; i++) {
				var temp = arrStr[i].split("=");
				if (temp[0] == key) {
					cookStr = unescape(temp[1]); //取出并且解密
				}
			}

			return cookStr;
		}
	};
})();

util.local = (function() {
	return {
		put: function(k, v) {
			if (window.localStorage) {
				window.localStorage.setItem(k, v);
			}else{
				util.cookie.put(k,v);
			}
		},
		get: function(k) {
			return window.localStorage ? window.localStorage.getItem(k) : util.cookie.get(k);
		}
	};
})();

util.getQuery=function(name){
			var vars = [], hash;
		    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
		    for(var i = 0; i < hashes.length; i++)
		    {
		      hash = hashes[i].split('=');
		      vars.push(hash[0]);
		      vars[hash[0]] = hash[1];
		    }
		    return vars[name];
		}

